cmake_minimum_required(VERSION 3.8)
project(hardware)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(realtime_tools REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(driver REQUIRED)
find_package(shared_parameters REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)

add_library(
  hardware
  SHARED
  src/hardware.cpp
  src/interface.cpp
)

target_include_directories(
  hardware
  PUBLIC
  include
  ${driver_INCLUDE_DIRS}
)
#target_link_libraries(
#  ${PROJECT_NAME}
#  Boost::system
#)
ament_target_dependencies(
  hardware
  hardware_interface
  rclcpp
  rclcpp_lifecycle
  realtime_tools
  std_msgs
  std_srvs
  driver
)

# prevent pluginlib from using boost
target_compile_definitions(hardware PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(
  hardware_interface hardware.xml)

install(
  TARGETS
  hardware
  RUNTIME DESTINATION bin
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
)

install(
  DIRECTORY include/
  DESTINATION include
)

install(
  DIRECTORY config launch
  DESTINATION share/${PROJECT_NAME}
)

install(
  DIRECTORY description/ros2_control description/urdf  description/launch description/rviz
  DESTINATION share/${PROJECT_NAME}
)

ament_export_include_directories(
  include
)
ament_export_libraries(
  hardware
)
ament_export_dependencies(
  hardware_interface
  pluginlib
  rclcpp
  rclcpp_lifecycle
)

ament_package()
